<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncGetOrder.php,v $
 * $Author: pcornelissen $
 * $Revision: 1.2 $
 * $Date: 2003/12/08 12:09:47 $
 *
 * Type: Function
 *
 * gets an order from the db and assign the order array to a given name
 * @param ordernumber
 * @param assign - (optional) the variable name for the result, default= Order
 */
function smarty_function_pncGetOrder($params, &$smarty)
{
    if (!pnSecAuthAction( 0, "pncommerce::invoice", "::", ACCESS_ADMIN ) )
    {
        return;
    }
    
    extract($params);

    if( !pnModLoad( 'pncommerce', 'user' ) )
    {
        return false;
    }

    if ( !pnModAPILoad( 'pncommerce', 'user' ) )
    {
        return false;
    }

    if( !$assign )
    {
        $assign = 'Order';
    }

    if( !$OrderNumber )
    {
        return "*** missing parameter 'OrderNumber' in pncGetOrder ***";
    }
    $order = pnModAPIFunc( 'pncommerce', 'user', 'getOrder',
                           array( 'ON' => $OrderNumber ) );
    
    $smarty->assign( $assign, $order );
}
?>
